package com.cskaoyan.controller;

import com.cskaoyan.bean.User;
import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author stone
 * @date 2022/10/07 09:26
 */
//@Controller
//@ResponseBody
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    UserService userService;

    // 先获得user的信息
    @RequestMapping("create")
    public User create(HttpServletRequest request,
                       HttpServletResponse response) {//args = new Object[]{request,response}
        String username = request.getParameter("username");

        User user = new User();
        user.setUsername(username);

        userService.createUser(user);

        return user;
    }
}
